package com.example.petstore.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.petstore.entity.Order;
import com.example.petstore.entity.Product;
import com.example.petstore.entity.Shop;
import com.example.petstore.mapper.ShopMapper;
import com.example.petstore.service.IProductService;
import com.example.petstore.service.IShopService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.petstore.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author DD
 * @since 2024-07-04
 */
@Service
public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IShopService {

    @Autowired
    private IProductService productService;

    @Override
    public Result getOneShop(int shopId) {
        QueryWrapper<Product> queryWrapper= new QueryWrapper<>();
       queryWrapper.eq("shop_id",shopId);
        List<Product> list = productService.list(queryWrapper);

        return Result.success(list);


    }

    @Override
    public Result getAllShop(int current, int size) {
        Page<Shop> orderPage = new Page<>(current, size);
        this.page(orderPage);

        return Result.success(orderPage.getRecords());
    }
}
